package com.wb.jar;

import android.content.*;

public class BatteryReceiver extends BroadcastReceiver
{
    public static BatteryChangeListener batteryListener;

    public static void setListener(final BatteryChangeListener batteryListener) {
        BatteryReceiver.batteryListener = batteryListener;
    }

    public void onReceive(final Context context, final Intent intent) {
        final int n = intent.getExtras().getInt("level") * 100 / intent.getExtras().getInt("scale");
        final BatteryChangeListener batteryListener = BatteryReceiver.batteryListener;
        if (batteryListener != null) {
            batteryListener.OnBatteryChange(n);
        }
    }
}
